package com.example.js_interaction;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.example.js_interaction.localweb.LocalWebActivity;
import com.example.js_interaction.netweb.NetWebActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
    }

    /**
     * 点击按钮后跳转界面
     * @param view 点击的按钮对象
     */
    public void onClick(View view) {
        //创建Intent对象
        Intent intent = new Intent();
        if(view.getId()==R.id.Main_btn_id){
            //设置那个对象进行跳转
            intent.setClass(this, LocalWebActivity.class);
        }
        if(view.getId()==R.id.Main_btn_id1){
            //设置那个对象进行跳转
            intent.setClass(this, NetWebActivity.class);
        }
        //跳转函数
        startActivity(intent);
    }
}